import { defineStore } from 'pinia';
import { ref } from 'vue';
import { getDictList } from '@/api/dict';
export const useAppStore = defineStore('appStore', () => {



  // 修改密码状态
  const visiable = ref(false)

  const setVisiable = (val: boolean) => {
    visiable.value = val
  }

  // 字典列表
  const dictList = ref([]);

  // 两侧边栏的状态
  const showMenuLeft = ref(true);

  const showMenuRight = ref(true);

  // TODO: 放置请求字典数据
  const getDictListAction = async () => {
    const { data } = await getDictList();


    dictList.value = data;
  }

  // 设置两侧边栏的状态
  const setshowMenuLeft = async () => {
    showMenuLeft.value = !showMenuLeft.value

  }

  const setshowMenuRight = async () => {
    showMenuRight.value = true

  }

  const setHidenRight = async () => {
    showMenuRight.value = false

  }


  const setShowMenu = () => {
    if (showMenuLeft.value && showMenuRight.value) {
      showMenuLeft.value = false
      showMenuRight.value = false
    }
  }



  return {
    showMenuLeft,
    showMenuRight,
    dictList,
    visiable,
    setshowMenuRight,
    setHidenRight,
    getDictListAction,
    setshowMenuLeft,
    setShowMenu,
    setVisiable,
  }
})
